package com.sunwayworld.basemodule.samplemanage.sample.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.sunwayworld.basemodule.samplemanage.sample.service.LimsCourierService;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;
import com.sunwayworld.framework.spring.annotation.GikamBean;
import com.sunwayworld.framework.utils.NumberUtils;
import com.sunwayworld.framework.utils.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @ClassName LimsCourierServiceImpl
 * @Author zhoujq
 * @Date 2022/10/11
 * @Version 1.0
 **/
@Service
@GikamBean
public class LimsCourierServiceImpl implements LimsCourierService {

    @Override
    public JSONObject getCourierData(RestJsonWrapperBean jsonWrapperBean) {
        JSONObject req = new JSONObject();
        JSONArray rows = new JSONArray();

        String courierNumber = jsonWrapperBean.getParamValue("courierNumber");
        String courier = jsonWrapperBean.getParamValue("courier");
        Long id = NumberUtils.parseLong(jsonWrapperBean.getParamValue("id"));

        if (!StringUtils.isBlank(courier) && !StringUtils.isBlank(courierNumber)) {
            JSONObject row = new JSONObject();
            row.put("time", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
            row.put("location", "武汉");
            row.put("describe", "物流信息等未配置，数据仅供展示");
            rows.add(row);
        }

        req.put("rows", rows);
        return req;
    }
}
